package com.dellpc.amicool428_lld;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class WorkActivity extends AppCompatActivity {

    private EditText edName;
    private EditText etPassword;
    private Button btnLogin;
    private Button btnZhuCe;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_work);
        initView();

        setOnclick();
    }


    private void setOnclick() {
        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                login();
            }
        });
        btnZhuCe.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startAc();
            }
        });
    }

    private void initView() {
        edName = (EditText) findViewById(R.id.et_name);
        etPassword = (EditText) findViewById(R.id.et_password);
        btnLogin = (Button) findViewById(R.id.btn_login);
        btnZhuCe = (Button) findViewById(R.id.btn_zhuCe);
    }


    private void login() {
        String name = edName.getText().toString().trim();
        String pawword = etPassword.getText().toString().trim();
        if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pawword)) {
            return;
        }
        Toast.makeText(this, "login Success", Toast.LENGTH_SHORT).show();
    }

    private void startAc() {
        Intent intent = new Intent(this, ZhuCeActivity.class);
        startActivity(intent);
    }
}
